// pages/operation/operation.js
let app = getApp()
let request = require('../../utils/request')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    barHeight: wx.getMenuButtonBoundingClientRect().bottom,
    pageHeight: app.globalData.pageHeight,
    userInfo: {},
    callPhoneDialog: false,
    phoneNumber: '',
    parkingList: [],
    parkManagerList: [],
    currentPage: 1,
    pageSize: 10,
    canIUseGetUserProfile: false,
    managerName: wx.getStorageSync('username'),
    telephone: wx.getStorageSync('telephone'),
    activityTab: 2
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let data = wx.getStorageSync('lmtc_admin_shopInfo')
    if (wx.getUserProfile) {
      this.setData({
        canIUseGetUserProfile: true
      })
    }
    this.setData({
      managerName:wx.getStorageSync('username'),
      telephone:wx.getStorageSync('telephone'),
      activityTab: options.activityTab != null ? options.activityTab : 2,
      userInfo: {
        avatarUrl: data.avatar,
        nickName: data.nickName,
        phone: data.telephone,
        isOwner: data.isOwner
      }
    })
  },
  onShow() {
   
  },
  /**
   * 退出登录
   */
  logout() {
    wx.showModal({
      title: '操作确认',
      content: '是否确认退出登录？',
      confirmText: '确认退出',
      success(res) {
        if (res.confirm) {
          wx.reLaunch({
            url: '/pages/login/login',
          })
          wx.removeStorageSync('lmtc_admin_token')
          wx.removeStorageSync('lmtc_admin_shopInfo')
        }
      }
    })
  },
  /**
   * 切换页签
   */
  switchTab(e) {
    this.setData({ activityTab: e.currentTarget.dataset.index})
  },
  /**
   * 获取车场管理员列表
   */
  // getParkManagerList() {
  //   let that = this
  //   let parmas = {
  //     currentPage: this.data.currentPage,
  //     size: this.data.pageSize
  //   }
  //   request.http('/park/park-manager/page', 'GET', parmas)
  //     .then(res => {
  //       let data = res.data
  //       if (data.code == 200) {
  //         that.setData({
  //           parkManagerList: data.data.records
  //         })
  //       }
  //     })
  // },
    /**
   * 打开拨号弹窗
   */
  showCallPhoneDialog(e) {
    this.setData({ callPhoneDialog: true, phoneNumber: e.detail })
  },
  /**
   * 关闭拨号弹窗
   */
  hiddenCallPhoneDialog() {
    this.setData({ callPhoneDialog: false })
  },
  /**
   * 拨打电话
   */
  callPhone() {
    wx.makePhoneCall({ phoneNumber: this.data.phoneNumber })
    this.hiddenCallPhoneDialog()
  },
    /**
   * 查看详情
   */
  showInfo(e) {
    this.setData({ content: e.detail, infoDialog: true })
  },
    /**
   * 关闭弹窗
   */
  closeDialog(){
    this.setData({ infoDialog: false })
  },

})